package com.cndw.kungfu.model.player.domain;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.StringProcesser;
import com.cndw.kungfu.ext.XmlProcesser;

public class Dragon {
	
	private int level;
	
	private int upgradeExp;
	
	private String adds;
	
	private int[] addsVar;
	
	private static final String configFile = "dragon.xml";

	private static final Map<Integer, Dragon> officeMap = new ConcurrentHashMap<Integer, Dragon>();

	static {
		load();
	}

	public static synchronized void load() {
		String fileName = ConstantsConfig.getLocaleResource() + configFile;
		List<Dragon> officeList = XmlProcesser.processXml(Dragon.class, fileName);
		for (Dragon e : officeList) {
			officeMap.put(e.getLevel(), e);
		}
	}
	
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getUpgradeExp() {
		return upgradeExp;
	}

	public void setUpgradeExp(int upgradeExp) {
		this.upgradeExp = upgradeExp;
	}

	public String getAdds() {
		return adds;
	}

	public void setAdds(String adds) {
		this.adds = adds;
		try {
			addsVar = StringProcesser.toIntArray(adds);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

	public int[] getAddsVar() {
		return addsVar;
	}

	public void setAddsVar(int[] addsVar) {
		this.addsVar = addsVar;
	}

	public static Dragon getOne(int level) {
		return officeMap.get(level);
	}
	
	

}
